/*
 * Copyright (c) 2019 Aspire Tech,Inc. All rights reserved.
 */

package com.zenglx.demo;

import com.zenglx.assembly.avoidRepeatSubmit.RepeatSubmitException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class AssemblyExceptionHandler {

    /**
     * 处理各种未知运行异常
     */
    @ExceptionHandler(value = {RepeatSubmitException.class})
    public final ResponseEntity<?> handleException(Exception e) {
        log.error("{}未知异常:", e);
        HttpResponse result = new HttpResponse( 201, e.getMessage());
        return new ResponseEntity<>(result, HttpStatus.OK);
    }





}
